filename = "d:/01.jpg"

#with是一个上下文管理，会自动关闭file，不用执行close(
with open(filename,"rb") as rfile:
    with open("02.jpg","wb") as wfile:
        for i in rfile:
            wfile.write(i)